package com.constant;

import com.message.rpc.RpcResponseMessage;
import io.netty.util.concurrent.Promise;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author linyu.dai
 * @project rpc
 * @description 消息map
 * @creat 2022/11/28 10:07:42
 */
public class PromiseConstant {

    private static final Map<String, Promise<Object>> PROMISE_MAP = new ConcurrentHashMap<>();

    public static void setPromise(String messageId, Promise<Object> promise){
        PROMISE_MAP.put(messageId, promise);
    }

    public static Promise<Object> getPromise(String messageId){
        //用完删除
        return PROMISE_MAP.remove(messageId);
    }
}
